$.extend({
    getTypeLine(e) {
        const myChart = echarts.init(e, null);
        myChart.setOption({
            title: {
                text: '近俩年成果类型分布图',
                subtext: '测试数据'
            },
            legend: {
                type: 'scroll',
                orient: 'vertical',
                left: 'right',
                top: 45,
                bottom: 20
            },
            toolbox: {
                feature: {
                    saveAsImage: {},
                    restore: {}
                }
            },
            tooltip: {
                trigger: 'axis',
                showContent: true
            },
            xAxis: {type: 'category'},
            yAxis: {gridIndex: 0},
            grid: {top: '55%'}
        });

        myChart.showLoading();
        $.get('/result/get/byTypeWithYear', function (result) {
            myChart.hideLoading();
            let series = []
            result.payload.filter((t, index) => index > 0).map(t => series.push({type: 'line', smooth: true, seriesLayoutBy: 'row'}))
            series.push({
                type: 'pie',
                id: 'pie',
                top: '30',
                radius: '30%',
                center: ['50%', '25%'],
                label: {
                    formatter: '{b}: {@[1]}次 占比: {d}%'
                },
                encode: {
                    itemName: 0,
                    value: 1
                }
            })
            option = {
                dataset: {
                    source: result.payload
                },
                series: series
            }
            myChart.setOption(option);
        })

        myChart.on('updateAxisPointer', function (event) {
            var xAxisInfo = event.axesInfo[0];
            if (xAxisInfo) {
                var dimension = xAxisInfo.value + 1;
                myChart.setOption({
                    series: {
                        id: 'pie',
                        label: {
                            formatter: '{b}: {@[' + dimension + ']}次 占比: {d}%'
                        },
                        encode: {
                            value: dimension
                        }
                    }
                });
            }
        });
    }
})